Hi, how I can create function using DXl, which: string quote(string s) will return me the quoted s representation. For Example:
so to quote and to trim, white spaces. Dinio - Wed Dec 16 09:48:06 EST 2015 |
Re: Create function to quote string? Normally you employ regexp or work on character level for these kinds of functions. There are lots of examples for searching, splitting, trimming, replacing, etc. stuff in strings on the forum. You should take a look and come back with specific problems. Regards, Mathias |
Re: Create function to quote string? I try this:
But when try the quoteArgument function something strange happened: The result is:
On the second execution was:
I think this is some strange feature of DXL. |
Re: Create function to quote string? Dinio - Fri Dec 18 10:20:09 EST 2015 I try this:
But when try the quoteArgument function something strange happened: The result is:
On the second execution was:
I think this is some strange feature of DXL. I think the strange feature you are talking about is:
print quoteArgument(" asd asd ") "\n"
This is interpreted in DXL as
print quoteArgument (" asd asd " "\n" )
which will quote the newline. Functions with one parameter in DXL behave a bit strange, since you can leave out the parenthesis. print quoteArgument "Hallo" This makes the syntax ambiguous, thats why I tend to write function calls with one argument inside an expression always like this: print ( quoteArgument " asd asd ") "\n" Hope that helps. Regards, Mathias |
Re: Create function to quote string? Mathias Mamsch - Fri Dec 18 10:35:23 EST 2015 I think the strange feature you are talking about is:
print quoteArgument(" asd asd ") "\n"
This is interpreted in DXL as
print quoteArgument (" asd asd " "\n" )
which will quote the newline. Functions with one parameter in DXL behave a bit strange, since you can leave out the parenthesis. print quoteArgument "Hallo" This makes the syntax ambiguous, thats why I tend to write function calls with one argument inside an expression always like this: print ( quoteArgument " asd asd ") "\n" Hope that helps. Regards, Mathias I try
but the result is
"= I think the problem comes from the nested think. trim(str) in the quoteArgument print wrong thing when called in quoteArgument but if trim(str) is called separately everything is OK. |
Re: Create function to quote string? Dinio - Mon Jan 04 10:53:56 EST 2016 I try
but the result is
"= I think the problem comes from the nested think. trim(str) in the quoteArgument print wrong thing when called in quoteArgument but if trim(str) is called separately everything is OK. I copied your exact code beginning with "const string" and ending with "print quoteArgument(" asd asda ") " and added three times
print ( quoteArgument " asd asd ") "\n" The result is, as expected, exactly "asd asda""asd asd" "asd asd" "asd asd" Confirmed with DOORS 9.2 and DOORS 9.6.1.4 Is this really the complete code or are there other parts of the code which interfere with your result?
|
Re: Create function to quote string? Mike.Scharnow - Mon Jan 04 13:16:35 EST 2016 I copied your exact code beginning with "const string" and ending with "print quoteArgument(" asd asda ") " and added three times
print ( quoteArgument " asd asd ") "\n" The result is, as expected, exactly "asd asda""asd asd" "asd asd" "asd asd" Confirmed with DOORS 9.2 and DOORS 9.6.1.4 Is this really the complete code or are there other parts of the code which interfere with your result?
Only this code I have in the script.Doors 9.5.1.2. Can be from some switch of the rich client?
The result is still
|
Re: Create function to quote string? Dinio - Tue Jan 05 02:56:35 EST 2016 Only this code I have in the script.Doors 9.5.1.2. Can be from some switch of the rich client?
The result is still
It could be a namespace conflict with another function. Try the following: 0. Restart your DOORS client (you did that right?) 1. try string s = quoteArgument " asd asd " print s "\n" // should resolve the namespace conflict by explicitly telling DOORS which function to call 2. Use the original code but rename the "trim" function to something else. That should also resolve a namespace conflict. I remember something about a "trim" function, try this to make sure you are not having a problem with a top level function somehow taking precedence inside the expression. Regards, Mathias |
Re: Create function to quote string? Mathias Mamsch - Tue Jan 05 06:23:15 EST 2016 It could be a namespace conflict with another function. Try the following: 0. Restart your DOORS client (you did that right?) 1. try string s = quoteArgument " asd asd " print s "\n" // should resolve the namespace conflict by explicitly telling DOORS which function to call 2. Use the original code but rename the "trim" function to something else. That should also resolve a namespace conflict. I remember something about a "trim" function, try this to make sure you are not having a problem with a top level function somehow taking precedence inside the expression. Regards, Mathias I still can not explain to my self but obviously trim is occupied name. If I change it to trim2 everything works. I am much obliged to you for your patience boys during the recent difficulties.
|
Re: Create function to quote string? Dinio - Tue Jan 05 07:11:32 EST 2016 I still can not explain to my self but obviously trim is occupied name. If I change it to trim2 everything works. I am much obliged to you for your patience boys during the recent difficulties.
I found the thread about the ominous trim function: https://www.ibm.com/developerworks/community/forums/html/topic?id=efdabdc1-deab-4c63-acb2-037677a3ceeb&ps=25 As usual for DOORS: interesting and strange... |